package cn.lanqiao.springbootproject.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    /**
     * 定义demoQueue队列
     * @return
     */

    public Queue phoneQueue() {
        return new Queue("phoneQueue");
    }


    public Queue emailQueue() {
        return new Queue("emailQueue");
    }


    DirectExchange directExchange() {
        return new DirectExchange("directExchange");
    }

    @Bean
    public Binding bindingExchangeWithPhone() {
        return BindingBuilder.bind(phoneQueue()).to(directExchange()).with("phone");
    }

    @Bean
    public Binding bindingExchangeWithEmail() {
        return BindingBuilder.bind(emailQueue()).to(directExchange()).with("email");
    }
}
